<template>
  <ul>
    <li v-for="message in messageList" :key="message.id">
      <!-- <router-link :to="`/home/message/detail?id=${message.id}&title=${message.title}`">{{message.title}}</router-link>&nbsp;&nbsp; -->
      <!-- <router-link :to="`/home/message/detail/${message.id}/${message.title}`">{{message.title}}</router-link> -->

      <router-link
        :to="{
          //path:'/home/message/detail',
          name: 'xiangqing',
          params: {
            //query
            id: message.id,
            title: message.title,
          },
        }"
      >
        {{ message.title }}
      </router-link>
      <button @click="pushShow(message)">push查看</button>
      <button @click="replaceShow(message)">replace查看</button>
    </li>
    <hr />
    <router-view></router-view>
  </ul>
</template>

<script>
export default {
  name: "Message",
  data() {
    return {
      messageList: [
        { id: "001", title: "消息1" },
        { id: "002", title: "消息2" },
        { id: "003", title: "消息3" },
      ],
    };
  },
  methods: {
    pushShow(message) {
      this.$router.push({
        name: "xiangqing",
        params: {
          id: message.id,
          title: message.title,
        },
      });
    },
    replaceShow(message) {
      this.$router.replace({
        name: "xiangqing",
        params: {
          //query
          id: message.id,
          title: message.title,
        },
      });
    },
  },
};
</script>

<style>
</style>